/*
 * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.inspur.edp.cef.generator.apiGenerator;

import com.inspur.edp.cef.designtime.api.IGspCommonField;
import com.inspur.edp.cef.gencommon.MediateType;
import com.inspur.edp.cef.generator.entityGenerator.base.dataTypeData.DataTypeDataGenerator;
import com.inspur.edp.cef.generator.entityGenerator.base.elements.ElementAssoGenerator;
import com.inspur.edp.cef.generator.entityGenerator.base.elements.ElementEnumGenerator;
import com.inspur.edp.cef.generator.entityGenerator.base.nodeConst.DataTypeConstGenerator;
import com.inspur.edp.das.commonmodel.IGspCommonModel;
import com.inspur.edp.das.commonmodel.IGspCommonObject;

public final class ApiHelper {
  public static String getMgrAssFactoryInterfaceClassName(IGspCommonModel model) {
    String nameSpace = getCmNamespace(model);
    String ItemNameTemplate = "I" + model.getCode() + "MgrActionAssemblerFactory";
    return new MediateType(nameSpace, ItemNameTemplate).getFullName();
  }

  public static String getBEEntityInterfaceClassName(IGspCommonObject obj) {
    String nameSpace = getCmNamespace(obj.getBelongModel());
    String ItemNameTemplate = "I" + obj.getCode() + "BizEntity";
    return new MediateType(nameSpace, ItemNameTemplate).getFullName();
  }

  public static String getBeEntityAllInterfaceClassName(IGspCommonObject obj) {
    String nameSpace = getCmNamespace(obj.getBelongModel());
    String ItemNameTemplate = "I" + obj.getCode() + "entity";
    return new MediateType(nameSpace, ItemNameTemplate).getFullName();
  }

  public static String getBEMgrInterfaceClassName(IGspCommonModel model) {
    String nameSpace = getCmNamespace(model);
    String itemNameTemplate = "I" + model.getCode() + "BEManager";
    return new MediateType(nameSpace, itemNameTemplate).getFullName();
  }

  public static String getBEMgrAllInterfaceClassName(IGspCommonModel model) {
    String nameSpace = getCmNamespace(model);
    String itemNameTemplate = "I" + model.getCode() + "Service";
    return new MediateType(nameSpace, itemNameTemplate).getFullName();
  }

  public static String getDataTypeDataClassName(IGspCommonObject obj) {

    String nameSpace = obj.getGeneratedEntityClassInfo().getClassNamespace();
    String itemNameTemplate = DataTypeDataGenerator.getName(obj);
    return new MediateType(nameSpace, itemNameTemplate).getFullName();
  }

  public static String getDataTypeSerializerItemClassName(IGspCommonObject obj) {

    String nameSpace = obj.getGeneratedEntityClassInfo().getClassNamespace();
    String itemNameTemplate = obj.getCode() + "SerItem";
    return new MediateType(nameSpace, itemNameTemplate).getFullName();
  }

  public static String getDataTypeConstClassName(IGspCommonObject obj) {

    String nameSpace = obj.getGeneratedEntityClassInfo().getClassNamespace();
    String itemNameTemplate = DataTypeConstGenerator.getName(obj);
    return new MediateType(nameSpace, itemNameTemplate).getFullName();
  }

  public static String getElementAssoClassName(IGspCommonField field) {

    String nameSpace = field.getBelongObject().getGeneratedEntityClassInfo().getClassNamespace();
    String itemNameTemplate = ElementAssoGenerator.getName(field);
    return new MediateType(nameSpace, itemNameTemplate).getFullName();
  }

  public static String getElementEnumClassName(IGspCommonField field) {

    String nameSpace = field.getBelongObject().getGeneratedEntityClassInfo().getClassNamespace();
    String itemNameTemplate = ElementEnumGenerator.getName(field);
    return new MediateType(nameSpace, itemNameTemplate).getFullName();
  }

  private static String getCmNamespace(IGspCommonModel model) {
    return model.getApiNamespace().getDefaultNamespace();
  }
}
